package com.qf.controller;

import com.alibaba.fastjson.JSON;
import com.qf.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/*
杨威
2021/9/23
17:29
*/
@WebServlet("/login2")
public class LoginController2 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        User user = JSON.parseObject(request.getInputStream(), User.class);
        System.out.println("user = " + user);
        PrintWriter writer = response.getWriter();
        if(user!=null){
            writer.println(1);
        }else {
            writer.println(0);
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
